<template>
	<view>
		<view class="nav-pic">
			<text class="navTitle">VIP会员</text>
			<u-tabs :list="list1"  :activeStyle="{
						color: '#fff',
						fontWeight: 'bold',
						transform: 'scale(1.05)'
					}" :inactiveStyle="{
						color: '#fff',
						transform: 'scale(1)'
					}"></u-tabs>
		</view>
		<view class="card">
			 <image class="bgp" src="/static/images/juxing98.png" mode=""></image>
			 <view class="headers">
				 <view class="l">
				 	<image src="/static/images/zu428.png"></image>
				 </view>
				 <view v-if="!Isvip">
					 <view class="r">
						
							<text>欢迎你,朋友</text>
							<button type="default" @tap="openVip">开通</button>
					 </view>
					 <text class="r2">8元开通VIP,畅学名厨独家菜谱</text>
				 </view>
				<view v-else>
					 <view class="r">
							<text>欢迎你,靓仔</text>
							<button type="default" @tap="openVip">续费</button>
					 </view>
					 <text class="r2">8元续费VIP,畅想尊贵VIP服务</text>
				 </view>
			 </view>
			<view class="footer">
				 <view class="footer-one">
						<image src="/static/images/mengbanzu254.png" mode=""></image>
						<text>名厨课程</text>
				 </view> <view class="footer-one">
						<image src="/static/images/mengbanzu255.png" mode=""></image>
						<text>无广告</text>
				 </view> <view class="footer-one">
						<image src="/static/images/mengbanzu256.png" mode=""></image>
						<text>身份标识</text>
				 </view>
			</view>
		</view>
		<view class="type-item">
				<text>VIP最新推荐</text>
				 <scroll-view scroll-x anable-flex >
				 	<view class="section-item" v-for="item in newProData" :key="item._id">
								
									<videoOne :item="item"></videoOne>
						
						
				 	</view>
				 </scroll-view>
		</view><view class="type-item">
				<text>限时免费体验</text>
				 <scroll-view scroll-x anable-flex >
				 	<view class="section-item" v-for="item in freeProData" :key="item._id">
			<!-- 	 		<foodone :item="item" @tap="getDetail(item._id)"></foodone> -->
						<videoOne :item="item"></videoOne>
				 	</view>
				 </scroll-view>
		</view>
		<text style="margin-left: 30rpx;">猜你喜欢</text>
		<view class="guess">
				
			<view class="section-item" v-for="item in likeProData" :key="item._id">
				<foodone :item="item" @tap="getDetail(item._id)"></foodone>
			</view>
		</view>
		<text style="margin-left: 30rpx;">精品名厨，会员专享</text>
		<view class="guess">
				
			<view class="section-item" v-for="item in vipProData" :key="item._id">
				<foodone :item="item" @tap="getDetail(item._id)"></foodone>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list1: [{
					name: '推荐'
				}, {
					name: '免费体验'
				}, {
					name: '小白入门'
				}, {
					name: '快手菜'
				}, {
					name: '家常菜'
				}, {
					name: '川菜'
				}, {
					name: '粤菜'
				}, {
					name: '凉菜'
				}],
				newProData:[],
				freeProData:[],
				likeProData:[],
				vipProData:[],
			}
		},
		onLoad() {
			this.getNewPro()
			this.getFreePro()
			this.getLikePro()
			this.getVipPro()
		},
		onShow(){
			this.token= wx.getStorageSync("user_token")
			console.log("token",this.token);
			this.getNewPro()
			this.getFreePro()
			this.getLikePro()
			this.getVipPro()
		},
		computed:{
			Isvip(){
					return getApp().globalData.userInfo.vip
			},
			 token:{
				 get(){
					  return wx.getStorageSync("user_token")
				 },
				 set(val){
					 console.log('触发',val);
					 return val
				 }
				
			 }
		},
		methods: {
			async getNewPro(){
				const data=await this.$api.vip.getNewPro({token:this.token})
					this.newProData=data.menus
				console.log("新品推荐",data);
			},
				async getFreePro(){
				const data=await this.$api.vip.getFreePro({token:this.token})
					// console.log("免费",data);
						this.freeProData=data.menus
			
			},	async getLikePro(){
				const data=await this.$api.vip.getLikePro({token:this.token})
				// console.log("猜你喜欢",data);
				  this.likeProData=data.menus
			},	async getVipPro(){
				const data=await this.$api.vip.getVipPro({token:this.token})
				// console.log("vip精选",data);
					  this.vipProData=data.menus
			},
			openVip(){
				const token=wx.getStorageSync("user_token")
				 if(token){
					 uni.navigateTo({
					 	url:"../openVip/openVip"
					 })
				 }else{
					  uni.showModal({
					  	content: '请先登录',
					  	showCancel: false
					  });
					  // console.log(this.token);
				 }
			},
			getDetail(id){
				console.log(id);
				uni.navigateTo({
					url:"../datail/datail?_id="+id
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.nav-pic {
		height: 180rpx;
		background-image: url("/static/images/ditu.png");
		overflow: hidden;

		.navTitle {
			display: block;
			width: 200rpx;
			text-align: center;
			margin: 65rpx auto 10rpx;
			font-size: 35rpx;
		}


	}
	.card{
		
		width: 680rpx;
		height: 400rpx;
		margin: 30rpx auto;
		border-radius: 30rpx;
		position: relative;
		.bgp{
			width: 100%;
			height: 100%;
			position: absolute;
			z-index: -3;
		}
		.headers{
			height: 280rpx;
			padding: 30rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			.l{
				width: 200rpx;
				height: 100%;
				display: flex;
				align-items: center;
				image{
					width: 80%;
					height: 160rpx;
				}
			}
			.r{
				width:400rpx ;
				display: flex;
				margin-bottom: 30rpx;
				margin-top: 35rpx;
				color: rgb(147,147,147);
				font-family: 26rpx;
				
				button{
					width: 130rpx;
					height: 40rpx;
					line-height: 40rpx;
					border-radius: 40rpx;
					font-size: 27rpx;
					color: #868600;
					background-image: linear-gradient(to bottom,#e7b799,#f3d7be);
					margin-left: 80rpx;
					
				}
			}
			.r2{
				font-size: 30rpx;
				font-weight: bold;
				color: white;
			}
		}
		.footer{
			height: 120rpx;
			border-bottom-left-radius:18rpx ;
			border-bottom-right-radius: 18rpx;
			background-image: linear-gradient(to bottom,#000,#666);
			display: flex;
			justify-content: space-around;
			.footer-one{
				width: 150rpx;
				text-align: center;
				
				image{
					width: 50rpx;
					height: 50rpx;
					margin-top: 10rpx;
				}
				text{
					display: block;
					color: #bea78d;
					font-size: 24rpx;
				}
			}
			
		}
	}
scroll-view{
	margin-left: 35rpx;
	display: flex;
	white-space: nowrap;
	margin-top: 20rpx;
	.section-item {
		width: 300rpx;
		height: 400rpx;
		display: inline-block;
		margin-right: 50rpx;
	
	}
	}
.type-item{
	margin-bottom: 35rpx;
	>text{
		display: block;
		margin-left: 20rpx;
	}
}
.guess{
	width: 680rpx;
	margin: 20rpx auto 40rpx;
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
}

</style>
